home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / hcsvga12.zip / HCTGAV.C < prev    next >
Text File  |  1992-01-08  |  2KB  |  80 lines

  1. /*
  2.  * HCTGAV.C
  3.  *
  4.  * Copyright 1990,1991 Synergrafix Consulting
  5.  *          All Rights Reserved.
  6.  *
  7.  * December 31,1991
  8.  *
  9.  */
  10.  
  11. #include <stdio.h>
  12. #include "hctarga.h"
  13.  
  14. char infilename[128];
  15. char errmsg[256];
  16.  
  17. void error(char *s) {
  18.     fcloseall();
  19.     hctextmode();
  20.     printf("%s\n",s);
  21.     exit(1);
  22.     }
  23.  
  24. int main(int argc,char *argv[]) {
  25.  
  26.     int err,mode,w,h,commentsize;
  27.     unsigned char comment[256];
  28.  
  29.     if (argc!=2)
  30.         error("Usage: HCVTGA tgafilename");
  31.  
  32.     strcpy(infilename,argv[1]);
  33.  
  34.                         /* Get size of TGA file */
  35.  
  36.     err=hctgasize(infilename,&w,&h,&commentsize,&comment);
  37.     switch (err) {
  38.         case HCTGACANTOPEN:
  39.             error("Can't open input file!");
  40.             break;
  41.         case HCTGANOMEM:
  42.             error("Not enough memory to load file!");
  43.         case HCTGANOTSUPPORTED:
  44.             error("File type not supported!");
  45.         case HCTGACANTREAD:
  46.             error("Error reading file!");
  47.         }
  48.  
  49.                         /* Set Hicolor mode */
  50.     mode=hcmodesize(w,h);
  51.     if (mode<2) mode=2;
  52.     if (mode>3) mode=3;
  53.     if (!hcsetmodetseng(mode))
  54.         error("No HiColor DAC, not Tseng Chipset, or can't set mode!");
  55.  
  56.  
  57.                         /* View TGA file */
  58.  
  59.     err=hctgaview(infilename,-1,-1,-1,-1,0);
  60.     switch (err) {
  61.         case HCTGACANTOPEN:
  62.             error("Can't open input file!");
  63.             break;
  64.         case HCTGANOMEM:
  65.             error("Not enough memory to load file!");
  66.         case HCTGANOTSUPPORTED:
  67.             error("File type not supported!");
  68.         case HCTGACANTREAD:
  69.             error("Error reading file!");
  70.         }
  71.  
  72.     getch();                               /* Exit */
  73.  
  74.     hctextmode();
  75.  
  76.     return 0;
  77.     }
  78.  
  79.  
  80.